package packet1;

import java.util.*;

public class bytedance {
    static long sum = 0;
    static List<Integer> path = new ArrayList<>();
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n,d;
        n = sc.nextInt();
        d = sc.nextInt();
        int[] builds = new int[n];
        for (int i = 0; i < n; i++) {
            builds[i] =sc.nextInt();
        }
        dfs(builds, 0, d);
        System.out.println(sum % 99997867);
    }
    public static void dfs(int[] builds, int index, int d){
        if(path.size() == 3)
        {
            sum++;
            return;
        }
        for(int j = index; j < builds.length; j++)
        {

            for (int k = 0; k < path.size(); k++) {
                if(Math.abs(builds[j] - path.get(k) ) > d) {
                    return;
                }
            }
            path.add(builds[j]);
            dfs(builds, j + 1, d);
            path.remove(path.size() - 1);
        }
    }
}
/*
4 3
1 2 3 4
 */